|
In programming, operator overloading—less commonly known as operator ad hoc polymorphism—is a specific case of polymorphism, where different operators have different implementations depending on their arguments. Operator overloading is generally defined by the language, the programmer, or both. ==Motivation== Operator overloading is syntactic sugar, and is used because it allows the developer to program using notation closer to the target domain〔(【引用サイトリンク】url=http://www.parashift.com/c++-faq-lite/operator-overloading.html#faq-13.2 )〕 and allows user-defined types a similar level of syntactic support as types built into the language. It is common, for example, in scientific computing, where it allows computational representations of mathematical objects to be manipulated with the same syntax as on paper. Operator overloading does not change the expressive power of a language (with functions), as it can be emulated using function calls; for example, consider variables a, b, c of some user-defined type, such as matrices:a + b * c In a language that supports operator overloading, and with the usual assumption that the ' *' operator has higher precedence than '+' operator, this is a concise way of writing: add (a, multiply (b,c)) However, the former syntax reflects common mathematical usage. 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「operator overloading」の詳細全文を読む スポンサード リンク
|